<?php

use yii\db\Migration;

class m170619_022311_create_guild extends Migration
{

    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=MyISAM';
        }

        $this->createTable('{{%guild}}', [
            'id' => $this->primaryKey()->unsigned()->comment('自增id'),
            'guild_name' => $this->string()->notNull()->unique()->comment('公会名称'),
            'guild_sign' => $this->string()->notNull()->unique()->comment('公会标识(推荐拼音缩写)'),
            'guild_contact' => $this->string(32)->notNull()->comment('公会联系人'),
            'guild_phone' => $this->string(15)->notNull()->comment('手机号'),
            'guild_qq' => $this->string(20)->defaultValue('')->comment('QQ'),
            'guild_status' => $this->boolean()->notNull()->defaultValue(0)->comment('状态'),
            'guild_bank' => $this->integer()->defaultValue(0)->comment('银行信息'),
            'guild_game' => $this->integer()->defaultValue(0)->comment('游戏信息'),
            'guild_divide' => $this->decimal(32,2)->defaultValue(0)->comment('分成比例'),
            'guild_deducted' => $this->decimal(32,2)->defaultValue(0)->comment('扣量比例'),
            'add_time' => $this->integer()->notNull()->defaultValue(0)->comment('添加时间'),
        ], $tableOptions);
    }

    public function down()
    {
        $this->dropTable('{{%guild}}');
    }
}
